package application.controller 
{
	import application.event.SimpleModelEvent;
	import application.model.LevelModel;
	import application.model.vo.LevelVO;
	import application.view.LevelView;
	import application.view.SceneHolder;
	import flash.events.Event;
	/**
	 * ...
	 * @author Tiago Salomon
	 */
	public class LevelController 
	{
		private var _levelModel		:LevelModel;
		private var _level			:LevelView;		
		
		public function LevelController() 
		{
		}
		
		public function loadLevels():void 
		{
			this._levelModel = new LevelModel();
			this._levelModel.load();
			this._levelModel.addEventListener(Event.COMPLETE, levelModelCompleteHandler);			
		}
		
		private function levelModelCompleteHandler(e:Event):void 
		{
			this._level = new LevelView();
			this.showLevel(1);
		}
		
		private function showLevel(dificulty:Number):void
		{
			for each (var item:LevelVO in this._levelModel.levels) 
			{
				if (item.dificulty == dificulty)
					this._level.levelVO = item;
			}
			
			this._level.show();
		}
		
		public function hideLevel():void 
		{
			this._level.hide();
		}
		
		public function get level():LevelView 
		{
			return _level;
		}
		
	}

}
